<div class="bina_user goodsmanager">
    <div class="nav">
        <a href="#admin/bina"><div class="nav-li">商品分销</div></a>
        <div class="nav-li focus">分销人员</div>
    </div>
    <hr />

    <div class="infobox">

        <div class="bina_user goods_list">
            <h4>购买分销商品的用户列表</h4>
            <div class="add-form">
                <android:input label="用户昵称、手机号码、邮箱" value="{{$Cache.bina_user.user_maybe_info_to_add}}" bind-input="{{'$Cache.bina_user.user_maybe_info_to_add'}}" description="添加的用户默认享有目前所有分销商品的分销权"></android:input>
                <button event-click="{{'$Event.bina_user.add_user_to_all_bina'}}">添加用户</button>
            </div>
            <table>
                <thead>
                    <td><tip title="???">用户名</tip></td>
                    <td>手机号/邮箱</td>
                    <td>支付宝账号</td>
                    <td>一级返利</td>
                    <td>二级返利</td>
                    <td>三级返利</td>
                    <td>已兑现额度</td>
                    <td>可兑现额度</td>
                    <td>操作</td>
                </thead>
                {{#each $Cache.bina.user_list}}
                <tr>
                    <td>{{user.info.name}} 
                        <android:icon type="action-grade" color="goldenrod" style="{{#IndexOf $Top.bus_loginer.permission.data_forever_bina_user_list, user._id,'','display:none;'}}" class="hint--top" data-hint="永久分销权"></android:icon>
                        <android:icon type="device-brightness-high" color="goldenrod" style="{{#IndexOf $Top.bus_loginer.permission.data_senior_bina_user_list, user._id,'','display:none;'}}" class="hint--top" data-hint="享有高级分销规则"></android:icon>
                    </td>
                    <td>{{user.info.mobile_phone||user.info.email}}</td>
                    <td>{{#if user.info.alipay}}{{user.info.alipay}}{{#else}}<i>用户未绑定</i>{{/if}}</td>
                    <td style="text-align:center;">￥{{#Fixed total_first_acc}}</td>
                    <td style="text-align:center;">￥{{#Fixed total_second_acc}}</td>
                    <td style="text-align:center;">￥{{#Fixed total_third_acc}}</td>
                    <td style="text-align:center;">￥{{#Fixed exchange_acc.exchanged_acc}}</td>
                    <td style="text-align:center;">￥{{#Fixed can_apply_acc}}</td>
                    <td>
                        <!-- {{#if exchange_acc.state === $Top.config.BINA_STATE.未申请兑换}}
                            <i>用户未申请兑换</i>
                        {{/if}}
                        {{#if exchange_acc.state === $Top.config.BINA_STATE.申请兑换中}}
                            <button event-click="{{'$Top.$Event.bina_申请兑换中_to_商家已付款'}}">商家已打款</button>
                        {{/if}}
                        {{#if exchange_acc.state === $Top.config.BINA_STATE.商家已付款}}
                            <i>等待用户收款</i>
                        {{/if}} -->
                        <button event-click="{{'$Top.$Event.bina_user.edit_bina_list'}}">管理可分销商品</button>
                    </td>
                </tr>
                {{/each}}
            </table>
        </div>
        <android:dialogWindow show="{{$Cache.bina_user.editing.user_bina}}">
            <android:dialogWindow:contents>

                <div class="manager-user-bina_list">
                    <h4>当前编辑用户的信息：</h4>
                    <br>
                    <div class=" inline-block half-width" >
                        <center>
                        <p>
                            <img class="user-header" bind-src="{{$Cache.bina_user.editing.user_bina.user.info.header_url||'/images/default_head.jpg'}}?imageView/1/w/80/h/80" alt="用户头像" style="border-radius: 50%;border: 1px #0058D1 solid;">
                            <p><b>{{$Cache.bina_user.editing.user_bina.user.info.name}}</b></p>
                        </p>
                        <p><b>手机号：</b>{{$Cache.bina_user.editing.user_bina.user.info.mobile_phone}}</p>
                        <p><b>邮箱：</b>{{$Cache.bina_user.editing.user_bina.user.info.email}}</p>
                        <p><b>支付宝账号：</b>
                            {{#if $Cache.bina_user.editing.user_bina.user.info.name}}
                            {{$Cache.bina_user.editing.user_bina.user.info.name}}
                            {{#else}}
                            <i>用户未绑定</i>
                            {{/if}}
                        </p>
                        </center>
                    </div>
                    <div class="bina_list goods_list inline-block half-width">
                        <div class="hr-bottom">
                            {{#if window.jSouper.indexOf(bus_loginer.permission.data_senior_bina_user_list, $Cache.bina_user.editing.user_bina.user._id)!==-1}}
                            <android:paperbutton event-click="{{'$Event.bina_user.remove_user_form_senior_bina_user_list'}}">取消高级分销权限</android:paperbutton>
                            {{#else}}
                            <android:paperbutton event-click="{{'$Event.bina_user.add_user_to_senior_bina_user_list'}}">授予高级分销权限</android:paperbutton>
                            {{/if}}
                            <br>
                            <br>
                        </div>
                        <br>
                        <div style="{{#IndexOf bus_loginer.permission.data_forever_bina_user_list,$Cache.bina_user.editing.user_bina.user._id,'display:none',''}};">
                            <h5>分销商品列表：
                                <android:paperbutton event-click="{{'$Event.bina_user.add_user_to_bina_list'}}">一键添加全部</android:paperbutton>
                                <android:paperbutton event-click="{{'$Event.bina_user.add_user_to_forever_bina_user_list'}}">授予永久分销权限</android:paperbutton>
                            </h5>
                            <table class="paper-table">
                                <thead>
                                    <td class="logo">缩略图</td>
                                    <td class="name">名称</td>
                                    <td class="method">操作</td>
                                </thead>
                                {{#each $Cache.bina.bina_list}}
                                <tr>
                                    <td><img bind-src="{{goods.preview_img_url}}?imageView/1/w/25/h/25" alt="{{goods.goods_name}}的缩略图"></td>
                                    <td><a title="{{goods._id}}" href="{{$Top.bus_loginer.url}}/goods-details.html?id={{goods._id}}">{{goods.goods_name}}</a></td>
                                    
                                    <td>
                                        <div hidden="{{#ArrayOwn $Top.$Cache.bina_user.editing.bina_id_list,bina._id}}">
                                            <button event-click="{{'$Top.$Event.bina_user.add_user_to_bina'}}">添加到用户分销商品列表</button>
                                        </div>
                                        <div hidden="{{#ArrayNoOwn $Top.$Cache.bina_user.editing.bina_id_list,bina._id}}">
                                            <!-- <i>已添加</i>  -->
                                            {{#if bina.user_map[$Top.$Cache.bina_user.editing.user_bina.user._id].is_lock}}
                                            <android:paperbutton layer-num=0 event-click="{{'$Top.$Event.bina_user.unlock_user_from_bina'}}"><android:icon type="action-lock-open"></android:icon>解冻分销权限</android:paperbutton>
                                            {{#else}}
                                            <android:paperbutton event-click="{{'$Top.$Event.bina_user.lock_user_from_bina'}}"><android:icon type="action-lock-outline"></android:icon>冻结分销权限</android:paperbutton>
                                            {{/if}}
                                        </div>
                                    </td>
                                </tr>
                                {{/each}}
                            </table>
                        </div>
                        <div style="{{#IndexOf bus_loginer.permission.data_forever_bina_user_list,$Cache.bina_user.editing.user_bina.user._id,'','display:none'}};">
                            <div class="inline-block"><b>用户享有所有分销商品的分销权</b></div>
                            <div class="inline-block">
                                <android:paperbutton event-click="{{'$Event.bina_user.remove_user_form_forever_bina_user_list'}}">取消永久分销权限</android:paperbutton>
                            </div>
                        </div>
                    </div>
                </div>

            </android:dialogWindow:contents>
            <android:dialogWindow:actions>
                <android:dialogWindow:action>
                <android:paperbutton event-click="{{'$Event.bina_user.close_edit'}}">关闭</android:paperbutton>
                </android:dialogWindow:action>
            </android:dialogWindow:actions>
        </android:dialogWindow>

    </div>
</div>
<style>
    .bina_user .add-form .android-input{
        display:inline-block;
        width:260px;
    }
    .bina_user .manager-user-bina_list{
        /*padding-top:2em;*/
    }
    .bina_user .manager-user-bina_list .user-header{
        width:80px;
        height:80px;
        display:block;
    }
</style>